home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Xconq 7.0d37 / source / kernel / lisp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-20  |  5.7 KB  |  187 lines  |  [TEXT/KAHL]

  1. /* Definitions for Lisp objects in Xconq.
  2.    Copyright (C) 1989, 1991, 1992, 1993, 1994, 1995 Stanley T. Shebs.
  3.  
  4. Xconq is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.  See the file COPYING.  */
  8.  
  9. #ifndef LISP_H
  10. #define LISP_H
  11.  
  12. /* Lisp objects in Xconq are pretty basic, since they are used only for
  13.    game definition and (usually) not the core computations. */
  14.  
  15. /* The different types of Lisp objects. */
  16.  
  17. enum lisptype {
  18.   NIL,
  19.   CONS,
  20.   NUMBER,
  21.   STRING,
  22.   SYMBOL,
  23.   UTYPE,
  24.   MTYPE,
  25.   TTYPE,
  26.   POINTER,
  27.   EOFOBJ
  28.   };
  29.  
  30. /* Declaration of a cons cell. */
  31.  
  32. struct a_cons {
  33.     struct a_obj *car;
  34.     struct a_obj *cdr;
  35. };
  36.  
  37. /* A symbol includes its index and a pointer to its binding. */
  38.  
  39. struct a_symbol {
  40.     long symnum;
  41.     struct a_obj *value;
  42. };
  43.  
  44. /* A pointer is an address with associated name.  Interpretation
  45.    and usage is up to the context. */
  46.  
  47. struct a_pointer {
  48.     struct a_obj *sym;
  49.     char *data;
  50. };
  51.  
  52. /* The basic Lisp object.  This should be small. */
  53.  
  54. typedef struct a_obj {
  55.     enum lisptype type;          /* type of the object */
  56.     union {
  57.     int num;       /* numeric value */
  58.     char *str;     /* string value */
  59.     struct a_symbol sym;
  60.     struct a_cons cons;
  61.     struct a_pointer ptr;
  62.     } v;               /* the "content" of the object */
  63. } Obj;
  64.  
  65. /* The symbol table is the way to map names into symbols. */
  66.  
  67. typedef struct a_symentry {
  68.     char *name;
  69.     struct a_obj *symbol;
  70.     char constantp;
  71. } Symentry;
  72.  
  73. /* A stream is just a union of string pointer and file pointer. */
  74.  
  75. enum strmtype { stringstrm, filestrm };
  76.  
  77. typedef struct a_strm {
  78.     enum strmtype type;
  79.     union {
  80.     char *sp;
  81.     FILE *fp;
  82.     } ptr;
  83. } Strm;
  84.  
  85. /* Enum of all the random keywords. */
  86.  
  87. enum keywords {
  88.  
  89. #undef  DEF_KWD
  90. #define DEF_KWD(name,CODE,value)  CODE,
  91.  
  92. #include "keyword.def"
  93.  
  94.     LAST_KEYWORD
  95. };
  96.  
  97. #define match_keyword(ob,key) \
  98.   (symbolp(ob) && strcmp(c_string(ob), keyword_name(key)) == 0)
  99.  
  100. /* All the Lisp interface declarations. */
  101.  
  102. extern Symentry *symboltable;
  103.  
  104. extern Obj *lispnil;
  105. extern Obj *lispeof;
  106.  
  107. extern void init_lisp PROTO ((void));
  108. extern int strmgetc PROTO ((Strm *strm));
  109. extern void strmungetc PROTO ((int ch, Strm *strm));
  110. extern Obj *read_form PROTO ((FILE *fp, int *p1, int *p2));
  111. extern Obj *read_form_from_string PROTO ((char *str, int *p1, int *p2));
  112. extern void sprintf_line_numbers PROTO ((char *buf, int start, int end));
  113. extern Obj *read_form_aux PROTO ((Strm *strm));
  114. extern Obj *read_list PROTO ((Strm *strm));
  115. extern int read_delimited_text PROTO ((Strm *strm, char *delim, int spacedelimits, int eofdelimits));
  116. extern int length PROTO ((Obj *list));
  117. extern Obj *new_string PROTO ((char *str));
  118. extern Obj *new_number PROTO ((int num));
  119. extern Obj *new_utype PROTO ((int u));
  120. extern Obj *new_mtype PROTO ((int r));
  121. extern Obj *new_ttype PROTO ((int t));
  122. extern Obj *new_pointer PROTO ((Obj *sym, char *ptr));
  123. extern Obj *cons PROTO ((Obj *x, Obj *y));
  124. extern void type_warning PROTO ((char *funname, Obj *x, char *typename, Obj *subst));
  125. extern Obj *car PROTO ((Obj *x));
  126. extern Obj *cdr PROTO ((Obj *x));
  127. extern Obj *cadr PROTO ((Obj *x));
  128. extern Obj *cddr PROTO ((Obj *x));
  129. extern Obj *caddr PROTO ((Obj *x));
  130. extern char *c_string PROTO ((Obj *x));
  131. extern int c_number PROTO ((Obj *x));
  132. extern Obj *intern_symbol PROTO ((char *str));
  133. extern int lookup_string PROTO ((char *str));
  134. extern Obj *symbol_value PROTO ((Obj *sym));
  135. extern Obj *setq PROTO ((Obj *sym, Obj *x));
  136. extern void makunbound PROTO ((Obj *sym));
  137. extern void flag_as_constant PROTO ((Obj *sym));
  138. extern int constantp PROTO ((Obj *sym));
  139. extern int numberp PROTO ((Obj *x));
  140. extern int stringp PROTO ((Obj *x));
  141. extern int symbolp PROTO ((Obj *x));
  142. extern int consp PROTO ((Obj *x));
  143. extern int utypep PROTO ((Obj *x));
  144. extern int mtypep PROTO ((Obj *x));
  145. extern int ttypep PROTO ((Obj *x));
  146. extern int pointerp PROTO ((Obj *x));
  147. extern int boundp PROTO ((Obj *sym));
  148. extern int numberishp PROTO ((Obj *x));
  149. extern int equal PROTO ((Obj *x, Obj *y));
  150. extern int member PROTO ((Obj *x, Obj *lis));
  151. extern Obj *elt PROTO ((Obj *lis, int n));
  152. extern void fprintlisp PROTO ((FILE *fp, Obj *obj));
  153. extern void fprint_list PROTO ((FILE *fp, Obj *obj));
  154. extern void sprintlisp PROTO ((char *buf, Obj *obj));
  155. extern void sprint_list PROTO ((char *buf, Obj *obj));
  156. extern void dlisp PROTO ((Obj *x));
  157. extern Obj *append_two_lists PROTO ((Obj *x1, Obj *x2));
  158. extern Obj *append_lists PROTO ((Obj *lis));
  159. extern Obj *remove_from_list PROTO ((Obj *elt, Obj *lis));
  160. extern void push_binding PROTO ((Obj **lis, Obj *key, Obj *val));
  161. extern void push_int_binding PROTO ((Obj **lis, Obj *key, int val));
  162. extern void push_key_binding PROTO ((Obj **lis, int key, Obj *val));
  163. extern void push_key_cdr_binding PROTO ((Obj **lis, int key, Obj *val));
  164. extern void push_key_int_binding PROTO ((Obj **lis, int key, int val));
  165. extern Obj *eval PROTO ((Obj *x));
  166. extern Obj *eval_symbol PROTO ((Obj *x));
  167. extern Obj *eval_list PROTO ((Obj *x));
  168.  
  169. /* Functions that the Lisp code needs to have defined. */
  170.  
  171. extern void init_warning PROTO ((char *str, ...));
  172. extern void low_init_warning PROTO ((char *str));
  173. extern void init_error PROTO ((char *str, ...));
  174. extern void low_init_error PROTO ((char *str));
  175. extern void run_warning PROTO ((char *str, ...));
  176. extern void low_run_warning PROTO ((char *str));
  177. extern void run_error PROTO ((char *str, ...));
  178. extern void low_run_error PROTO ((char *str));
  179. extern void announce_read_progress PROTO ((void));
  180. extern int keyword_code PROTO ((char *str));
  181. extern char *keyword_name PROTO ((enum keywords k));
  182. extern int keyword_value PROTO ((enum keywords k));
  183. extern int lazy_bind PROTO ((Obj *sym));
  184. extern void init_predefined_symbols PROTO ((void));
  185.  
  186. #endif /* LISP_H */
  187.